package com.zm.demo.spring.ioc.main;

import com.zm.demo.spring.ioc.factorybean.MyFactoryBean;
import com.zm.demo.spring.ioc.po.UserPO1;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class SimpleIOC {


    public static void main(String[] args) throws Exception {

        BeanFactory beanFactory = new FileSystemXmlApplicationContext("classpath:META-INF/spring-ioc.xml");
        System.out.println("byId: " + beanFactory.getBean("userPO").toString());
        System.out.println("byType: " + beanFactory.getBean(com.zm.demo.spring.ioc.po.User.class).toString());

        UserPO1 userPO1 = (UserPO1) beanFactory.getBean("userPO2");
        System.out.println("byFactoryBean: "+userPO1.toString());


    }
}
